﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Rotempco.ORM.Generator.Templates
{
    public class ADALCodebehindTemplate
    {
        public static string GetTemplate()
        {
            return @"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using @ProjectName.Core.ORM.ADAL;
using System.Data.SqlClient;
using @ProjectName.BaseClass.Objects.EntityObjects;
using @ProjectName.Core.ORM.Objects;
using @ProjectName.Core.ORM.Objects.Enums;
using @ProjectName.Core.ORM.Logic;
using @ProjectName.Core.Logic;
@EnumNamespaces
@SerializableNamespaces
namespace @DALImplementationNamespace
{
    public partial class @DomainClassData : @ADALType<@DomainClass,@PrimaryType>
    {
	    #region [ ADATA Implementation ]

        protected override string GetTableName()
        {
            return ""@TableName"";
        }

        protected override Pair<string, string> GetIdentity()
        {
            return new Pair<string, string>(""@PrimaryKey"", SymbolExtensions.GetPropertyName((@DomainClass d) => d.@PrimaryKey));
        }

        protected override List<ORMParameter> GetORMMapping()
        {
            List<ORMParameter> mapping = new List<ORMParameter>();
		
@DALORMMapping
            return mapping;
        }

        #endregion

        #region [ GetBy ]

        public @DomainClass GetSingle(bool getDeleted = false, @ParameterListAttributes @WithPreCommaNullableParameterListAttributes)
        {
            List<PropertyPair> parameterList = GetByParameterList(@ParameterListCall);
            List<NullablePair> nullablePairList = GetNullablePairList(@NullableParameterListCall);
            return GetBy(parameterList, getDeleted, nullablePairList: nullablePairList).SingleOrDefault();
        }

        public List<@DomainClass> GetList(bool getDeleted = false, long? getFirstEntries = null, long? getLastEntries = null, @ParameterListAttributes @WithPreCommaNullableParameterListAttributes)
        {
            List<PropertyPair> parameterList = GetByParameterList(@ParameterListCall);
            List<NullablePair> nullablePairList = GetNullablePairList(@NullableParameterListCall);
            return GetBy(parameterList, getDeleted, getFirstEntries, getLastEntries, nullablePairList: nullablePairList);
        }

        #endregion

        #region [ Private ]

        private List<PropertyPair> GetByParameterList(@ParameterListAttributes)
        {
            List<PropertyPair> mapping = new List<PropertyPair>();

@ParameterListMapping
            return mapping;
        }

        private List<NullablePair> GetNullablePairList(@NullableParameterListAttributes)
        {
            List<NullablePair> nullablePairList = new List<NullablePair>();

@NullableParameterListMapping

            if (nullablePairList.Count <= 0)
                return null;

            return nullablePairList;
        }

        #endregion

	}
}

";
        }
    }
}
